package com.itheima.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        //构建批量注册侧插件的对象
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        //mp内置的分页对象
        PaginationInnerInterceptor innerInterceptor = new PaginationInnerInterceptor();
        //设置分页大小受限
        innerInterceptor.setMaxLimit(-1l);
        //设置操作的数据库类型
        innerInterceptor.setDbType(DbType.MYSQL);
        //注册分页插件
        mybatisPlusInterceptor.addInnerInterceptor(innerInterceptor);
        return mybatisPlusInterceptor;
    }
}
